package org.wanho.rent.util;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;

public class ResponseUtil {

	/**
	 * 把数据返回浏览器页面
	 * @param msg 字符串提示信息
	 * @param obj返回的对象
	 * @param isSuccess 成功、失败的标识
	 * @param response 响应对象（固定参数）
	 * @throws IOException
	 */

	public static void doResponse(String msg, Object obj, boolean isSuccess, HttpServletResponse response)
			throws IOException {
		AjaxResult ar = new AjaxResult(isSuccess, msg, obj);
		// 转成json字符串返回页面
		String jsonStr = JSON.toJSONString(ar);
		PrintWriter out = response.getWriter();
		out.print(jsonStr);
	}

}
